﻿Option Strict On
Option Explicit On
Option Infer On

Imports System
Imports System.Collections.Generic
Imports System.Xml.Linq
Imports GenDotNet.Task.Common
Imports GenDotNet.ObjectModel
Imports <xmlns:orm="http://kadgen.com/KADORM.xsd">

Namespace GenInputMetadata
   Public Class ClassPrivilegeData
      Inherits BaseData
      Implements IClassPrivilegeData


      Private mObjectData As IObjectData

      Private Shared Function Load( _
               ByVal objectData As ObjectData, _
               ByVal element As XElement) _
               As ClassPrivilegeData
         Dim ret As New ClassPrivilegeData(objectData.RootData, element)
         Return ret
      End Function

      Public Shared Function Load( _
               ByVal objectData As ObjectData, _
               ByVal elements As IEnumerable(Of XElement)) _
               As List(Of IClassPrivilegeData)
         Dim ret = New List(Of IClassPrivilegeData)
         For Each XElement In elements
            ret.Add(Load(objectData, XElement))
         Next
         Return ret
      End Function

      Private Sub New(ByVal rootData As RootData, _
                      ByVal element As XElement)
         MyBase.New(rootData, element)
      End Sub


      Public ReadOnly Property CanCreate() As Boolean Implements IClassPrivilegeData.CanCreate
         Get
            Return Element.@Rights.Contains("C") Or Element.@Rights.Contains("c")
         End Get
      End Property

      Public ReadOnly Property CanDelete() As Boolean Implements IClassPrivilegeData.CanDelete
         Get
            Return Element.@Rights.Contains("D") Or Element.@Rights.Contains("d")
         End Get
      End Property

      Public ReadOnly Property CanRetrieve() As Boolean Implements IClassPrivilegeData.CanRetrieve
         Get
            Return Element.@Rights.Contains("R") Or Element.@Rights.Contains("r")
         End Get
      End Property

      Public ReadOnly Property CanSetSelect() As Boolean Implements IClassPrivilegeData.CanSetSelect
         Get
            Return Element.@Rights.Contains("S") Or Element.@Rights.Contains("s")
         End Get
      End Property

      Public ReadOnly Property CanUpdate() As Boolean Implements IClassPrivilegeData.CanUpdate
         Get
            Return Element.@Rights.Contains("U") Or Element.@Rights.Contains("u")
         End Get
      End Property

      Public ReadOnly Property Grantee() As String Implements IClassPrivilegeData.Grantee
         Get
            Return Element.@Grantee
         End Get
      End Property
   End Class
End Namespace

